const { defineConfig } = require('@vue/cli-service')

const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
require('events').EventEmitter.defaultMaxListeners = 0
module.exports = defineConfig({

  transpileDependencies: true,
  // 关闭语法检查
  lintOnSave:false,
  outputDir: './build',
  // 和webpapck属性完全一致，最后会进行合并
  configureWebpack: {
    // title: "IWu",
    resolve: {
      alias: {
        components: '@/components'
      }
    },
    //配置webpack自动按需引入element-plus，
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  },
  devServer: {
    open: true,
    host: 'localhost',
    port: 8080,
    //这里的ip和端口是前端项目的;下面为需要跨域访问后端项目
    proxy: {
      // 注册
     '/api/': {
        target: 'http://127.0.0.1:5000/',//这里填入你要请求的接口的前缀
        ws:true,//代理websocked
        changeOrigin:true,//虚拟的站点需要更管origin
        secure: true,                   //是否https接口
        pathRewrite:{
          '^/api/':''//重写路径
        },
        // headers: {
        //   referer: 'http://localhost:8081/ResourcesCenter/', //这里后端做了拒绝策略限制，请求头必须携带referer，否则无法访问后台
        // }
      },
     
    }
    
  }



})
